<?PHP
 session_start();
 include("admin/include/db.php");
 include("includes/function.php");


  if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'forgot_password'){
	
	$user_email 	= mysql_real_escape_string($_REQUEST['user_email']);
    
	$sqlCategory = mysql_query("SELECT * FROM software_user WHERE email = '$user_email'");
	$resCategory = mysql_fetch_array($sqlCategory); 
	$emailAddress= $resCategory["email"]; 
	
	$randomNumber= generatePassword(); 

		
	if($emailAddress != '')
	{
		mysql_query("UPDATE software_user SET password = '".$randomNumber."' where email = '$user_email'");
		
		$to		 =	$user_email;
		$from 	 = "nospam@softwarecoursesonline.com";
		$subject = "Confirm your registration at softwarecoursesonline.com!";
		
		$emailMessage = '
						<style type="text/css">
							.text {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }						
						</style>
						<table width="100%" cellpadding="2" cellspacing="2" class="text">																	
							<tr>
								<td colspan="2" align="left">&nbsp;</td>
							</tr>
							<tr>
								<td colspan="2" align="left">Forgot your password! </td>
							</tr>
							<tr>
								<td colspan="2" align="left" style="padding-top:10px">Please check your password in the give below</td>
							</tr>
							<tr>
								<td colspan="2" align="left" style="padding-top:10px">Email: '.$emailAddress.'</td>
							</tr>
							<tr>
								<td colspan="2" align="left" style="padding-top:10px">Password: '.$randomNumber.'</td>
							</tr>
							<tr>
								<td colspan="2" align="left" style="padding-top:10px">&nbsp;</td>
							</tr>
						</table>';
						
		emailFormat($to , $from , $subject , $emailMessage);
		header("location:forgot_password.php?msg=1");
		exit();	
		
	}
	else
		header("location:forgot_password.php?msg=2");
	exit();		
 }
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=TITLE_WEBSITE?></title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<script>s
function register_validation(){
	
	var message = '';
	var emailReg	  = document.getElementById("user_email").value;
	
	if(emailReg == ''){
		message += 'Please enter email address \n';	
	}
	
	if(emailReg != ""){
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    	var address = emailReg;
    	if(reg.test(address) == false) {
 			message += 'Please enter valid email address\n';
      	}
	}
	
	if(message != ""){
		alert(message);
		return false;	
	}
}


</script>
<body>
<center>
<div style="background:#179cc1; height:3px">&nbsp;</div>
<div style="width:990px;" align="center">
		<div id="header">
		<?php
    		include("includes/header.php");
   		?>
        </div>
        <div style="margin-top:23px; margin-bottom:21px" align="center" >
    	<?php
									$sqlAdvertise = mysql_query("SELECT * FROM software_advertise 
																	WHERE 
																		banner_status = 'Y' AND banner = 2
																		ORDER BY RAND()
																		");
									$resAdvertise = mysql_fetch_array($sqlAdvertise);
							
									$imgPath  = 'admin/upload_images/'.$resAdvertise["banner_image"];
									
								?>
								<a href="http://<?=$resAdvertise["banner_url"]?>" target="_blank" ><img border="0" src="<?=$imgPath?>"  width="729" height="86" /></a>
    </div>
    <div style="margin-top:20px;">
    	<div style="float:left; width:70%;" >
        	<div align="left" >
            	<span class="headingOrange" ><strong>Latest Headline</strong></span>
            </div>
           <div align="left"  >
       		    <?php
                	$sqlHeadings = mysql_query("SELECT * FROM software_headlines WHERE active = 'Y'");
					while($resHeadings = mysql_fetch_array($sqlHeadings)){
				?>
              <div class="text"  style="margin-top:15px; " >	
                  <div><span class="heading1"><strong><?php echo $resHeadings["headline_heading"]?></strong></span><br/> <br/><?php echo nl2br($resHeadings["headline_desc"])?></div>
          		  <div style=" border-bottom:1px dotted #000000; height:10px; padding-right:5px; width:95%" ></div>
                </div>
                   <?php
					}
				?>
       		</div>
        </div>
        <div style="float:right; width:30%" align="right">
        	<div style="margin-top:50px"><?php
									$sqlAdvertise = mysql_query("SELECT * FROM software_advertise 
																	WHERE 
																		banner_status = 'Y' AND banner = 3
																		ORDER BY RAND()
																		");
									$resAdvertise = mysql_fetch_array($sqlAdvertise);
							
									$imgPath  = 'admin/upload_images/'.$resAdvertise["banner_image"];
									
								?>
								
              </div>
              <div style="margin-top:50px"><?php
									$sqlAdvertise = mysql_query("SELECT * FROM software_advertise 
																	WHERE 
																		banner_status = 'Y' AND banner = 3
																		ORDER BY RAND()
																		");
									$resAdvertise = mysql_fetch_array($sqlAdvertise);
							
									$imgPath  = 'admin/upload_images/'.$resAdvertise["banner_image"];
									
								?>
								<!--<a href="http://<?=$resAdvertise["banner_url"]?>" target="_blank" ><img border="0" src="<?=$imgPath?>"   /></a>-->
              </div>                  
        </div>
        
      <div style="clear:both"></div>
    </div>
    
    <div style="margin-top:23px; margin-bottom:21px" align="center" >
    	<?php
									$sqlAdvertise = mysql_query("SELECT * FROM software_advertise 
																	WHERE 
																		banner_status = 'Y' AND banner = 2
																		ORDER BY RAND()
																		");
									$resAdvertise = mysql_fetch_array($sqlAdvertise);
							
									$imgPath  = 'admin/upload_images/'.$resAdvertise["banner_image"];
									
								?>
								<a href="http://<?=$resAdvertise["banner_url"]?>" target="_blank" ><img border="0" src="<?=$imgPath?>"  width="729" height="86" /></a>
    </div>
   </div>
   <div id="footer">
  		<?php include("includes/footer.php")?>
   </div>
</div>
	</div>
</center>
</body>
</html>
